package org.sky.configuration;
import org.apache.logging.log4j.Logger;
import org.sky.security.support.CustomSecurityFilter;
import org.sky.util.LogUtils;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

import java.beans.Encoder;

/**
 * @author weifx
 * @Title: ConfigBean
 * @ProjectName springboot-platform
 * @Description: TODO{其他配置Bean}
 * @date 2019/3/17 18:47
 * @Version 1.0
 */
@Component
public class ConfigBean {
    Logger log = LogUtils.getLogger(ConfigBean.class);

    /**
     * 停用托管在Spring容器中的CustomSecurityFilter
     * 解决Url请求过滤两次与静态资源被过滤的问题
     * @param mySecurityFilter
     * @return
     */
    @Bean
    public FilterRegistrationBean disableSecurityFilter(CustomSecurityFilter mySecurityFilter) {
        log.info("停用Spring容器中的过滤器{}",CustomSecurityFilter.class);
        FilterRegistrationBean registration = new FilterRegistrationBean(mySecurityFilter);
        registration.setEnabled(false);
        return registration;
    }
}
